//
//  CheckWorkViewController.m
//  TeamInformatization
//
//  Created by bigger on 2019/4/1.
//  Copyright © 2019年 SPIC. All rights reserved.
//

#import "CheckWorkViewController.h"
#import "CommonMessage.h"
#import "CommonMessageViewCell.h"
#import "TouchView.h"
#import "QuestionDetailViewController.h"
#import "DealQuestionViewController.h"
#import "AcceptDealDetailViewController.h"

@interface CheckWorkViewController () <UITableViewDataSource, UITableViewDelegate, ChangeContentViewDelegate, TouchViewDelegate>

@property (nonatomic, strong) UITableView *clockInListTableView;

@property (nonatomic, strong) NSMutableArray *clockInListArray;

@end

@implementation CheckWorkViewController

{
    TouchView *_creatCheckView, *_clockInView;
    
    int _currentNum;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self showTitleBarWithTitle:@"上岗到位" leftButtonStyle:Base_NavigationBar_Back rightButtonStyle:Base_NavigationBar_None];
    // 初始数据
    self.clockInListArray = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < 7; i++) {
        CommonMessage *message = [[CommonMessage alloc] init];
        message.title = @"上岗到位";
        message.subTitle1 = @"上岗人员";
        message.subTitle2 = @"上岗地点";
        message.date = @"2019-03-25 09:40:23";
        message.contentStr1 = @"张三李四王五等";
        message.contentStr2 = @"内蒙古呼和浩特";
        
        [self.clockInListArray addObject:message];
    }
    
    _currentNum = 0;
    
    [self loadShowViews];
}

// UI
- (void)loadShowViews
{
//    _creatCheckView = [[TouchView alloc] initWithFrame:CGRectMake(0, kSafeAreaTopHeight, kScreenWidth, 50 * kScaleWidth) TitleText:@"发布上岗到位" ImageStr:@"fabu"];
//    _creatCheckView.delegate = self;
//    [self.view addSubview:_creatCheckView];
//
//    _clockInView = [[TouchView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_creatCheckView.frame), kScreenWidth, 50 * kScaleWidth) TitleText:@"上岗到位" ImageStr:@"daowei"];
//    _clockInView.delegate = self;
//    [self.view addSubview:_clockInView];
    
    ChangeContentView *changeContentView = [[ChangeContentView alloc] initWithFrame:CGRectMake(0, kSafeAreaTopHeight, kScreenWidth, 40 * kScaleWidth) TitleArray:@[@"我发布的", @"我接受的", @"我完成的", @"发现的问题"]];
    changeContentView.delegate = self;
    [self.view addSubview:changeContentView];
    
    self.clockInListTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(changeContentView.frame), kScreenWidth,kSecondContentHeight - 40 * kScaleWidth) style:UITableViewStylePlain];
    [_clockInListTableView registerClass:[CommonMessageViewCell class] forCellReuseIdentifier:@"CommonMessage"];
    _clockInListTableView.delegate = self;
    _clockInListTableView.dataSource = self;
    _clockInListTableView.backgroundColor = [UIColor clearColor];
    _clockInListTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _clockInListTableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_clockInListTableView];
    
}

#pragma mark - TouchViewDelegate
- (void)getTouchwithTouchView:(TouchView *)touchView
{
    if (touchView == _creatCheckView) {
        
    }
    
    if (touchView == _clockInView) {
        
    }
}

#pragma mark - ChangeContentViewDelegate
- (void)getTouchNum:(int)touchNum withChangeContentView:(ChangeContentView *)changeContentView
{
    _currentNum = touchNum;
    
    switch (touchNum) {
        case 0: {
            
            break;
        }
        case 1: {
            
            break;
        }
        case 2: {
            
            
            
            break;
        }
        case 3: {
            
            break;
        }
        default:
            break;
    }
}


#pragma mark - TableViewDelegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _clockInListArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 152 * kScaleWidth;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    CommonMessage *commonMessage = [[CommonMessage alloc] init];
    if (self.clockInListArray.count != 0) {
        commonMessage = self.clockInListArray[indexPath.row];
    }
    
    CommonMessageViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CommonMessage" forIndexPath:indexPath];
    if (!cell) {
        cell = [[CommonMessageViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CommonMessage"];
    }
    
    [cell setShowCellWithCommonMessage:commonMessage];
    
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (_currentNum) {
        case 0: {
            
            break;
        }
        case 1: {
            QuestionDetailViewController *detailVC = [[QuestionDetailViewController alloc] init];
            [self.navigationController pushViewController:detailVC animated:YES];
            break;
        }
        case 2: {
            
            DealQuestionViewController *dealVC = [[DealQuestionViewController alloc] init];
            [self.navigationController pushViewController:dealVC animated:YES];
            
            break;
        }
        case 3: {
            
            AcceptDealDetailViewController *acceptVC = [[AcceptDealDetailViewController alloc] init];
            [self.navigationController pushViewController:acceptVC animated:YES];
            break;
        }
            
        default:
            break;
    }
}

#pragma -导航栏 两边按钮操作
-(void)baseNavigationBarLeftButtonClick:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
